<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>模拟配置管理 |模拟新增配置管理</title>
<@fm.header />
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 270px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post" enctype="multipart/form-data">
	<input type="hidden" name="id" value=${config.id}></input>
	<input type="hidden" name="code" value=${config.code}></input>
		
		<table>
	        <tr>
	            <td><label for="name">名称</label></td>
	            <td colspan="3"><input class="easyui-validatebox" type="text" name="name" style="width:400px" value=${config.name}></input></td>
	        </tr>

            <tr>
                <td><label for="brushTitle">标题</label></td>
                <td colspan="3"><input class="easyui-validatebox" type="text" name="brushTitle" style="width:400px" value="${config.brushTitle}"></input></td>
            </tr>

            <tr>
                <td><label for="url">链接:</label></td>
                <td colspan="3">
                    <input class="easyui-textbox" name="url" id="url" data-options="multiline:true;required:true;" style="width:400px;" value="${config.url}"></input>
				</td>
            </tr>

            <tr>
                <td><label>基地</label></td>
                <td>
                    <input id="cc" class="easyui-combobox" style="width: 155px;" name="baseId" data-options="
						required:true,
						url:'/base/content?defaultValues=${config.baseId}',
						method:'get',
						valueField:'id',
						textField:'baseName'" />
                </td>

                <td><label for="isLimit">新增分时段</label></td>
                <td>
					<select class="easyui-combobox" name="isLimit" panelHeight="auto" style="width:155px" data-options="required:true">
                    	<option value="0" <#if config.isLimit?exists && config.isLimit == 0>selected</#if>>否</option>
                    	<option value="1" <#if config.isLimit?exists && config.isLimit == 1>selected</#if>>是</option>
                	</select>
                </td>
            </tr>

	        <tr>
	           <td><label for="minTotal">日限最小值</label></td>
	            <td ><input id="minTotal" type="text" style="width:150px" name="minTotal" class="easyui-numberbox" min="0" precision="0" data-options="required:true" value=${config.minTotal}></input></td>
	            <td><label for="maxTotal">日限最大值</label></td>
	            <td><input id="maxTotal" type="text" style="width:150px" name="maxTotal" class="easyui-numberbox" min="0" precision="0" data-options="required:true" value=${config.maxTotal}></input></td>
	        </tr>

            <tr>
                <td><label for="brushTimeCheck">是否单独记录拉活时间</label></td>
                <td >
                    <input type="hidden" name="brushTimeFlag" id="brushTimeFlag" value="${config.brushTimeFlag}"></input>
                    <input type="checkbox"  id="brushTimeCheck" >
                </td>
            </tr>
            <tr>
                <td><label for="minFilterDay">最小间隔天</label></td>
                <td><input id="minFilterDay" type="text" style="width:150px" name="minFilterDay" class="easyui-numberbox" min="0" precision="0" data-options="required:true" value=${config.minFilterDay}></input></td>
                <td><label for="maxFilterDay">最大间隔天</label></td>
                <td><input id="maxFilterDay" type="text" style="width:150px" name="maxFilterDay" class="easyui-numberbox" min="0" precision="0" data-options="required:true" value=${config.maxFilterDay}></input></td>
            </tr>
	    </table>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="edit()">提交</a>
	</div>
</div>

<script>


    $(function(){

        if($("#brushTimeFlag").val()==1){
            $("#brushTimeCheck").attr("checked","checked");
        }



    });

    $("#brushTimeCheck").on('click',function(){
        if ($("#brushTimeCheck").is(':checked')) {
            $("#brushTimeFlag").val(1);
        } else {
            $("#brushTimeFlag").val(0);
        }
    })

function edit() {



	$('#ff').form(
	    'submit',
	    {
			url : '/brushConfig/updateConfig',
			onSubmit : function() {
				var minTotal = $("#minTotal").val();
				var maxTotal = $("#maxTotal").val();
				var str1 = parseFloat(minTotal);
				var str2 = parseFloat(maxTotal);
				if ( str1 > str2) {
				    top.showMsg(market.content.title, '最大小于最小值', alert);
					return false;
				}
				return $(this).form('enableValidation').form('validate');
			},
			success : function(data) {
				showProcess(false);
				var data = eval('(' + data + ')');
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		}); 
}
</script>
</body>
</html>